from bs4 import BeautifulSoup

# 读取 HTML 文件内容
with open('heros.txt', 'r', encoding='utf-8') as file:
    html_content = file.read()

# 解析 HTML
soup = BeautifulSoup(html_content, 'lxml')

# 获取所有 <a> 标签
paragraphs = soup.find_all('a')

# 打开文件准备写入
with open('heros_name.txt', 'w', encoding='utf-8') as out_file:
    for p in paragraphs:
        title = p.get('title')
        if title:
            out_file.write(f"{title}\n")
